package com.codemonkey.lq.test.sampledata;

import java.util.List;

import cn.hutool.core.collection.CollectionUtil;

public class PersonFactory {

	private static Person singletonInstance;
	static {
		singletonInstance = new Person();
		singletonInstance.setAge(19);
		singletonInstance.setName("Tom");
		singletonInstance.setGender("男");
	}

	public static List<Person> getSampleGroupData() {
		final Person person1 = new Person();
		person1.setAge(18);
		person1.setName("Mike");
		person1.setGender("男");

		final Person person2 = new Person();
		person1.setAge(17);
		person1.setName("Lucy");
		person1.setGender("女");

		final Person person3 = new Person();
		person1.setAge(19);
		person1.setName("Jerry");
		person1.setGender("男");

		return CollectionUtil.newArrayList(person1, person2, person3, getSinglePerSession());
	}

	/**
	 * 返回单例对象
	 * @return
	 */
	public static Person getSingletonData() {
		if (null == singletonInstance) {
			singletonInstance = getSinglePerSession();
		}
		return singletonInstance;
	}

	/**
	 * 每次请求返回值一个全新的对象
	 * @return
	 */
	public static Person getSinglePerSession() {
		final Person person = new Person();
		person.setAge(19);
		person.setName("Tom");
		person.setGender("男");
		return person;
	}
}
